{include file="public/header" /}

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.ds_article}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    
    <form id="article_form" method="post" action="{:url('Affiche/save')}">
        <table class="ds-default-table">
            <tbody>
                <input type="hidden"  name="id" value="{$affiche_id}">
                <tr class="noborder"> 
                    <td class="required w120 validation"><label for="title" class="validation">{$Think.lang.affiche_title}</label></td>
                    <td class="vatop rowform">
                        <input type="text" name="title" id="title" value="{$data.title|default=''}" placeholder="{$Think.lang.please_fill}{$Think.lang.affiche_title}" class="w200"/>
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <tr class="noborder"> 
                    <td class="required"><label for="typeid" class="validation">{$Think.lang.affiche_type}</label></td>
                    <td class="vatop">
                        <label>
                            <select name="typeid" id="typeid" style="width: 222px;">
                                <option value="">{$Think.lang.ds_please_choose}</option>
                                {foreach name="typeList" item="cate"}
                                    <option value="{$cate.id}" {if  ($cate.id == $data.typeid) } selected {/if} >{$cate.name|default=''}</option>
                                {/foreach}
                            </select>
                        </label>
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <tr class="noborder">
                    <td class="required"><label for="start_at"  class="validation">{$Think.lang.ds_start_time}:</label></td>
                    <td class="vatop">
                        <input type="text" style="width: 202px;" name="start_at" id="start_at" class="txt date" autocomplete="off" value="<?php echo !empty($data['start_time']) ? date('Y-m-d', $data['start_time']) : ''?>" >
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <tr class="noborder">
                    <td class="required"><label for="end_at"  class="validation">{$Think.lang.ds_end_time}:</label></td>
                    <td class="vatop">
                        <input type="text" style="width: 202px;" name="end_at" id="end_at" class="txt date" autocomplete="off" value="<?php echo  !empty($data['end_time']) ? date('Y-m-d', $data['end_time']) : ''?>">
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <tr class="noborder">
                    <td class="required">{$Think.lang.affiche_sort}</td>
                    <td class="vatop rowform">
                        <input type="text" name="sort" id="sort" placeholder="{$Think.lang.sort_rule}" value="{$data.sort|default=''}" class="w200"/></td>
                    <td class="vatop tips"></td>
                </tr>

                <tr class="noborder">
                    <td class="required"><label for="contents"  class="validation">{$Think.lang.affiche_content}:</label></td>
                    <td class="vatop rowform" colspan="2">
                        <textarea name="contents" id="contents" placeholder="{$Think.lang.please_fill}{$Think.lang.affiche_content}" style="width:60%;height: 150px;" title="公告内容">{$data.contents|default=''}</textarea>
                    </td>
                </tr>
            </tbody>
            <tfoot>
                <tr class="tfoot">
                    <td colspan="15"><input class="btn" type="submit"  style ='line-height: 30px;' value="{$Think.lang.ds_submit}"/></td>
                </tr>
            </tfoot>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        $('#start_at').datepicker({dateFormat: 'yy-mm-dd'});
        $('#end_at').datepicker({dateFormat: 'yy-mm-dd'});
    });
</script>
<script type="text/javascript">
    $(function() {
        $('#article_form').validate({
            errorPlacement: function(error, element) {
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules: {
                title : {
                    required: true
                },
                typeid : {
                    required: true
                },
                start_at : {
                    required: true
                },
                end_at : {
                    required: true
                },
                sort :{
                    number:true,
                    range:[0,255]
                },
                contents : {
                    required: true
                },
            },
            messages: {
                title : {
                    required   : '{$Think.lang.affiche_title_notnull}'
                },
                typeid : {
                    required   : '{$Think.lang.affiche_type_notnull}'
                },
                start_at : {
                    required   : '{$Think.lang.affiche_start_time_notnull}'
                },
                end_at : {
                    required   : '{$Think.lang.affiche_end_time_notnull}'
                },
                contents : {
                    required   : '不能为空'
                },
                sort:{
                    number: '{$Think.lang.affiche_sort_error}',
                    range:'{$Think.lang.affiche_sort_error}'
                }
            }
        });

    });
</script>